﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using _1242026_1242133.DTO;

namespace _1242026_1242133.DAO
{
    class KhachHangDAO
    {
        public DataTable ThemKhachHang(KhachHangDTO KhachHangDto)
        {
            SqlSever sql = new SqlSever();
            SqlParameter[] arrParam = {   new SqlParameter("@MaKhachHang", SqlDbType.VarChar), 
                                          new SqlParameter("@TenKhachHang", SqlDbType.VarChar),
                                          new SqlParameter("@CMND", SqlDbType.VarChar),           
                                          new SqlParameter("@DiaChi", SqlDbType.VarChar),
                                          new SqlParameter("@MaLoaiKhach", SqlDbType.VarChar),
                                      };
            arrParam[0].Value = KhachHangDto.MaKhachHang;
            arrParam[1].Value = KhachHangDto.TenKhachHang;
            arrParam[2].Value = KhachHangDto.CMND;
            arrParam[3].Value = KhachHangDto.DiaChi;
            arrParam[4].Value = KhachHangDto.MaLoaiKhach;
            return sql.ExecuteStore("sp_ThemKhachHang", arrParam);
        }

        public DataTable LoadDanhSachKhachHang()
        {
            SqlSever sql = new SqlSever();
            return sql.ExecuteCommandText("select * from KhachHang");
        }
    }
}
